# -*- encoding: utf-8 -*-
'''
@File    :   pay_and_Taxes_templet.py
@Time    :   2022/02/25 17:18:11
@Author  :   Potter 
@Version :   1.0
@Desc    :   None
'''

# start you srcipt now
#------------------------------------------------------------------------
#公司名称
print("xxxxx")

month_salary = 00

#月补贴
month_allowance = 00

#年终奖
year_award = 00

#租房开销
renting_house = 00

#生活开销
daliy = 00

print("收入明细：月薪：%d  月补贴 %d 年终奖 %d"%(month_salary,month_allowance,year_award))
print("综合年薪：%d "%((month_salary + month_allowance)*12 +year_award))
#------------------------------------------------------------------------
#2022上海上限：31014  
#2022重庆上限：24595

#公积金基数
social_security_benefit_base = 31014     

#公积金比例
social_security_benefit_rate = 0.12

#社保基数
housing_fund_base = 31014   

#社保比例 = 养老保险（8%）+ 医疗保险（%2）+ 失业保险（0.5%）+ 工商保险（0%）
housing_fund_rate = 0.105
#------------------------------------------------------------------------
#全年应纳税所得额
taxes_data_section = [    0,36000,144000,300000,420000,660000,960000]

#适用税率
taxes_rate_section =[ 0.03, 0.10,  0.20,  0.25,  0.30,  0.35,  0.45]
#------------------------------------------------------------------------
#全年应纳税所得额
year_award_data_section = [    0,3000,12000,25000,35000,55000,80000]

#适用税率
year_award_rate_section =[ 0.03, 0.10,  0.20,  0.25,  0.30,  0.35,  0.45]

#速算扣除数
year_award_remainder_section =[ 0, 210,  1410, 2660,  4410,  7160,  15160]
#------------------------------------------------------------------------

taxes_data_section_index = 1

curr_sum = 0
last_pay = 0

one_year_last_taxes_data = 0
one_year_curr_taxes_data = 0
per_month_real_data= 0

month_pay = month_salary + month_allowance
per_month_should_taxes_data = month_pay - social_security_benefit_base*social_security_benefit_rate - housing_fund_base*housing_fund_rate - 5000

for month_index in range(1,13):
	per_month_real_data= per_month_should_taxes_data
	one_year_curr_taxes_data = one_year_last_taxes_data + per_month_should_taxes_data
	for s in range (taxes_data_section_index,7):
		if taxes_data_section[s] <= one_year_curr_taxes_data :
			if one_year_last_taxes_data >= taxes_data_section[s -1]:
				per_month_real_data = per_month_real_data - (taxes_data_section[s]  -one_year_last_taxes_data)*taxes_rate_section[s-1]
			else:
				per_month_real_data = per_month_real_data - (taxes_data_section[s]  -taxes_data_section[s-1] )*taxes_rate_section[s-1]
				
		elif taxes_data_section[s] > one_year_curr_taxes_data:
			if one_year_last_taxes_data > taxes_data_section[s -1]:
				per_month_real_data = per_month_real_data - (one_year_curr_taxes_data - one_year_last_taxes_data)*taxes_rate_section[s-1]
			else:
				per_month_real_data = per_month_real_data - (one_year_curr_taxes_data  - taxes_data_section[s -1])*taxes_rate_section[s-1]
			
			one_year_last_taxes_data = one_year_curr_taxes_data
			taxes_data_section_index = s
			last_pay = per_month_real_data + 5000 + last_pay
			print("第 %d 月税后收入:%.2f" % (month_index,(per_month_real_data + 5000)))

			break
			
		else:
			print("算法错误")
print(" ")			
print("月度总收入\n%.2f"%(last_pay))
social_security_benefit_all = social_security_benefit_base*social_security_benefit_rate*24
print("公积金数值\n%.2f"%(social_security_benefit_all) )
print("月度总纳税\n%.2f"%((per_month_should_taxes_data + 5000)*12 - last_pay))
print(" ")		
#计算年终奖	
year_award_data_section = [    0,3000,12000,25000,35000,55000,80000]
year_award_rate_section =[ 0.03, 0.10,  0.20,  0.25,  0.30,  0.35,  0.45]
year_award_remainder_section =[ 0, 210,  1410, 2660,  4410,  7160,  15160]

year_award_month = year_award/12
for s in range (1,7):
	if year_award_data_section[s] > year_award_month:
		year_award_afer_tax = year_award*(1-year_award_rate_section[s-1]) + year_award_remainder_section[s-1]
		break

print("年终奖收入\n%.2f"%(year_award_afer_tax))	
print("年终奖纳税\n%.2f"%(year_award - year_award_afer_tax))	
print(" ")
print("房租  %d  日常生活  %d "%(renting_house,daliy))
print("年度结余数(无公积金)\n%.2f"%(year_award_afer_tax +last_pay - (renting_house + daliy)*12))
print("年度结余数(加公积金)\n%.2f"%(year_award_afer_tax +last_pay - (renting_house + daliy)*12 +social_security_benefit_all))